package com.atguigu.gmall.web.all.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.order.client.OrderFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.Map;

@Controller
public class OrderController {

    @Autowired
    private OrderFeignClient orderFeignClient;

    //  订单结算页控制器：
    //  http://order.gmall.com/trade.html
    @GetMapping("trade.html")
    public String trade(Model model){
        //  远程调用
        //  订单结算页面显示数据控制器. ${detailArrayList} ${totalNum} {totalAmount}
        Result<Map> result = orderFeignClient.trade();
        //  数据存储
        //  model.addAttribute("detailArrayList",result.getData().get("detailArrayList"));
        model.addAllAttributes(result.getData());
        //  订单结算页
        return "order/trade";
    }

    //  http://order.gmall.com/myOrder.html
    @GetMapping("myOrder.html")
    public String myOrder(){

        //  返回我的订单
        return "order/myOrder";
    }
}
